package cn.shyouchi.wuguanjia.android.ui.patrol.begin;

import android.view.View;
import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.R;

/**
 * Created by Eenie on 2017/1/5 at 12:14
 * Email: 472279981@qq.com
 * Des:
 */

public class PatrolManagerAdapter extends BaseQuickAdapter<PatrolManagerEntity.ResultMessageBean,BaseViewHolder> {


    public PatrolManagerAdapter(List<PatrolManagerEntity.ResultMessageBean> data) {
        super(R.layout.item_sel_repair_subitem_layout, data);
    }

    @Override
    protected void convert(final BaseViewHolder holder, final PatrolManagerEntity.ResultMessageBean entity) {

        holder.getView(R.id.img_del).setVisibility(View.VISIBLE);
        holder.getView(R.id.img_del).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getData().remove(holder.getPosition());
                notifyDataSetChanged();
            }
        });
        holder.setText(R.id.tv_subitem_name, entity.getName());
        final CheckBox cb = holder.getView(R.id.tv_subitem_name);
        cb.setChecked(entity.isChecked());
        cb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                entity.setChecked(!entity.isChecked());
                notifyItemChanged(holder.getAdapterPosition());
            }
        });
    }


}
